#include <iostream>

using namespace std;
/**
 * https://www.luogu.com.cn/problem/P1427
 */
int main(){
    int arr[110]{};
    int cnt = 0;
    while(true){
        int ai;
        cin >> ai;
        if (ai == 0){
            break;
        }

        arr[cnt] = ai;
        cnt++;
    }

    for(int i=cnt-1;i>=0;i--){
        cout << arr[i] << " ";
    }

    return 0;
}